package ooboo.gui;

import java.awt.Color;
import java.awt.Cursor;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

import javax.swing.JComponent;

import ooboo.Assets;

public class Link extends JComponent
{
	private static final long serialVersionUID = 1l;
	
	private int start;
	private int end;
	
	public Link(final String url,int start,int end)
	{
		this.start = start;
		this.end = end;
		
		addMouseListener(
				new MouseAdapter()
				{
					public void mouseClicked(MouseEvent e)
					{
						try
						{
							if (url.toLowerCase().contains("twitpic")){
								new TwitPic(url);
							} else {
								Assets.openUrl(url);
							}
						}
						catch(Exception e1)
						{
							// TODO Auto-generated catch block
							e1.printStackTrace();
						}
					}
				});
		setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
		setBackground(Color.RED);
		setOpaque(true);
	}
	
	public int getStart()
	{
		return start;
	}
	
	public int getEnd()
	{
		return end;
	}
}
